package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.core.annotation.Order;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Mapper
public interface OrderMapper {

    public void insert(Orders order);

    /**
     * 根据订单号查询订单
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    @Select("select * from orders where id=#{id}")
    Orders selectbyid(Long id);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    public Page<Orders> historypage(OrdersPageQueryDTO ordersPageQueryDTO);


    @Update("update orders set status=6 where id=#{id}")
    public void cancelorder(Long id);
    @Select("select count(id) from orders where status = #{status}")
    Integer countStatus(Integer status);
@Select("select * from orders where status=#{status} and order_time < #{time}")
    List<Orders> Timeoutorders(Integer status,LocalDateTime time);


Double summoney(LocalDateTime time,LocalDateTime time2,Integer status);

//    @Select("select count(id) from orders where order_time>#{start} and order_time<#{end}")
    public Integer orderreport(LocalDateTime start, LocalDateTime end,Integer status);

//    @Select("select count(id) from user where  order_time<#{end}")
    public Integer ordertotal( LocalDateTime end,Integer status);

    public List<GoodsSalesDTO> goodsaletopten(LocalDateTime start,LocalDateTime end);

}
